import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

import org.fioma.tree.suffixTree.bytes.SuffixTreeBytes;
import org.fioma.ui.Tools;

public class Test {

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) {
		try {
			System.out.println("Max Memory before tree create " + Runtime.getRuntime().maxMemory());
			System.out.println("Total Memory before tree create " + Runtime.getRuntime().totalMemory());
			System.out.println("Free Memory before tree create " + Runtime.getRuntime().freeMemory());
			long time = System.currentTimeMillis();
			SuffixTreeBytes tree = Tools.buildSuffixTree(args[0], Integer.parseInt(args[1]));
			System.out.println("Max Memory after tree create " + Runtime.getRuntime().maxMemory());
			System.out.println("Total Memory after tree create " + Runtime.getRuntime().totalMemory());
			System.out.println("Free Memory after tree create " + Runtime.getRuntime().freeMemory());
			System.out.println("Time to create the tree: " + (System.currentTimeMillis() - time));
			BufferedWriter bw = new BufferedWriter(new FileWriter("tree", false));
			byte[] prefix = new byte[1];
			prefix[0] = 0;
			tree.getRoot().printWords(bw, prefix);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
